<template>
    <view class="container">
        <view class="text-content">{{ list[currentIndex] }}</view>
        <view class="refresh" v-if="list.length > 1">
            <u-button
                @click="changeItem"
                icon="reload"
                :plain="true"
                shape="circle"
                text="换一个"
            ></u-button>
        </view>
    </view>
</template>

<script>
export default {
  data() {
    return {
      currentIndex: 0,
      list: []
    };
  },
  onLoad() {
    this.$util.request({
      url: '/userVoice/getExampleList'
    }).then(res => {
      this.list = res.data
    })
  },
  methods: {
    changeItem() {
      this.currentIndex++;
      if (this.currentIndex > this.list.length - 1) {
        this.currentIndex = 0;
      }
    }
  }
}
</script>
<style scoped>
@import './text-example.css';
</style>
